package com.bl.student.dao.repository;

import com.bl.student.dao.model.PayEntity;
import com.bl.student.dao.model.TeacherEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

/**
 * Created by yujingyi on 2018/4/22.
 */
public interface PayRepository extends PagingAndSortingRepository<PayEntity, String> {
    Page<PayEntity> findByPayer(String payer, Pageable pageable);

    Page<PayEntity> findByUserId(String payer, Pageable pageable);

    @Query(value = "select * from PAY where if(?1 !='',user_id=?1,1=1) and if(?2 !='',payer=?2,1=1) and if(?3 !='',status=?3,1=1) and if(?4 !='',apply_id=?4,1=1) ORDER BY create_time DESC \n#pageable\n",
            countQuery ="select * from PAY where if(?1 !='',user_id=?1,1=1) and if(?2 !='',payer=?2,1=1) and if(?3 !='',status=?3,1=1) and if(?4 !='',apply_id=?4,1=1) ",
            nativeQuery = true)
    Page <PayEntity>  findMultList(String user_id, String payer, String status, String apply_id, Pageable pageable );

}
